package com.kun.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqDirectConfig {

    //1. 声明交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("order_direct_exchange");
    }


    //2. 声明队列
    @Bean
    public Queue emailQueue_direct(){
        return new Queue("email_queue_direct");
    }

    @Bean
    public Queue smsQueue_direct(){
        return new Queue("sms_queue_direct");
    }


    //3. 绑定队列到交换机
    @Bean
    public Binding bindingEmailQueue_direct(){
        return BindingBuilder.bind(emailQueue_direct()).to(directExchange()).with("email");
    }

    @Bean
    public Binding bindingEmsQueue_direct(){
        return BindingBuilder.bind(smsQueue_direct()).to(directExchange()).with("sms");
    }


}
